|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
XMLBeansEJBDDParser.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
|
16 |
|
|
17 |
package org.apache.geronimo.ews.ws4j2ee.parsers;
|
|
18 |
|
|
19 |
import noNamespace.EjbJarDocument;
|
|
20 |
import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
|
|
21 |
import org.apache.geronimo.ews.ws4j2ee.context.impl.EJBDDContextImpl;
|
|
22 |
import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
|
|
23 |
import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
|
|
24 |
import org.apache.geronimo.ews.ws4j2ee.utils.Utils;
|
|
25 |
import org.w3c.dom.Document;
|
|
26 |
import org.w3c.dom.Element;
|
|
27 |
import org.w3c.dom.NodeList;
|
|
28 |
|
|
29 |
import java.io.InputStream;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Parse the ejb-jar.xml file and get the name of the EJB
|
|
33 |
*
|
|
34 |
* @author Srinath Perera(hemapani@opensource.lk)
|
|
35 |
*/
|
|
36 |
public class XMLBeansEJBDDParser { |
|
37 |
private J2EEWebServiceContext j2eewscontext;
|
|
38 |
private String ejbName = null; |
|
39 |
private EJBContext context;
|
|
40 |
|
|
41 | 0 |
public XMLBeansEJBDDParser(J2EEWebServiceContext j2eewscontext) {
|
42 | 0 |
this.j2eewscontext = j2eewscontext;
|
43 |
} |
|
44 |
|
|
45 | 0 |
public void parse(InputStream inputStream) throws GenerationFault { |
46 | 0 |
try {
|
47 | 0 |
EjbJarDocument ejbjarDoc = EjbJarDocument.Factory.parse(inputStream); |
48 | 0 |
EjbJarDocument.EjbJar ejbjar = ejbjarDoc.getEjbJar(); |
49 | 0 |
ejbjar.selectPath("ejb-jar/enterprise-beans/session/home");
|
50 | 0 |
Document doc = Utils.createDocument(inputStream); |
51 | 0 |
Element root = doc.getDocumentElement(); |
52 | 0 |
NodeList beaneles = root.getElementsByTagName("enterprise-beans");
|
53 | 0 |
if (beaneles.getLength() > 0) {
|
54 | 0 |
Element beanele = (Element) beaneles.item(0); |
55 | 0 |
NodeList sessionList = beanele.getElementsByTagName("session");
|
56 | 0 |
if (sessionList.getLength() > 0) {
|
57 | 0 |
Element session = (Element) sessionList.item(0); |
58 | 0 |
String ejbName = Utils.getElementValue(session.getElementsByTagName("ejb-name"));
|
59 | 0 |
String home = Utils.getElementValue(session.getElementsByTagName("home"));
|
60 | 0 |
String remote = Utils.getElementValue(session.getElementsByTagName("remote"));
|
61 | 0 |
String ejbClass = Utils.getElementValue(session.getElementsByTagName("ejb-class"));
|
62 | 0 |
context = new EJBDDContextImpl(ejbName,
|
63 |
ejbClass, |
|
64 |
home, remote, null, null); |
|
65 |
} else {
|
|
66 | 0 |
throw new GenerationFault("session tag not found"); |
67 |
} |
|
68 |
} else {
|
|
69 | 0 |
throw new GenerationFault("enterprise-beans tag not found"); |
70 |
} |
|
71 |
} catch (Exception e) {
|
|
72 | 0 |
e.printStackTrace(); |
73 | 0 |
throw GenerationFault.createGenerationFault(e);
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
/**
|
|
78 |
* @return
|
|
79 |
*/
|
|
80 | 0 |
public EJBContext getContext() {
|
81 | 0 |
return context;
|
82 |
} |
|
83 |
|
|
84 |
/**
|
|
85 |
* @param context
|
|
86 |
*/
|
|
87 | 0 |
public void setContext(EJBContext context) { |
88 | 0 |
this.context = context;
|
89 |
} |
|
90 |
|
|
91 |
} |
|
92 |
|
|